package com.jvtd.demo.umeng;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

import com.jvtd.demo.App;
import com.jvtd.demo.R;
import com.jvtd.umeng.JvtdUM;
import com.jvtd.utils.ChannelUtils;
import com.jvtd.widget.dialog.JvtdAlertDialog;
import com.jvtd.widget.toast.JvtdToast;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;

public class UmengActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_umeng);
        TextView ad1Btn = findViewById(R.id.btn1);
        TextView ad2Btn = findViewById(R.id.btn2);

        JvtdUM.getInstance(this).isDevelopment(true).init(App.UM_APP_ID, ChannelUtils.getChannelValue(this))
                .openLogin()
                .setWechat(App.WECHAT_APP_ID,App.WECHAT_APP_SECRET);

        ad2Btn.setOnClickListener(view -> share());
        ad1Btn.setOnClickListener(view -> login());
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        JvtdUM.getInstance(this).onActivityResult(requestCode,resultCode,data);
    }

    private void login() {
        JvtdToast.makeText(this,"没有账号无法测试",Toast.LENGTH_SHORT).show();
    }

    private void share() {
        JvtdUM.getInstance(this).shareImage(this, R.drawable.icon_image_empty, new UMShareListener() {
            @Override
            public void onStart(SHARE_MEDIA share_media) {

            }

            @Override
            public void onResult(SHARE_MEDIA share_media) {

            }

            @Override
            public void onError(SHARE_MEDIA share_media, Throwable throwable) {

            }

            @Override
            public void onCancel(SHARE_MEDIA share_media) {

            }
        });
    }
}

